class_name UI extends CanvasLayer


func _ready():
	$"技能描述".visible = false
	$"小子行动框".visible = false
	$"大子行动框".visible = false
	$"幽灵行动框".visible = false
	$"恶灵行动框".visible = false
	$"炮台行动框".visible = false
	$"狙炮行动框".visible = false
	$"地灵行动框".visible = false
	$"精灵行动框".visible = false
	$"沙兵行动框".visible = false
	$"沙皇行动框".visible = false
	$"野猪行动框".visible = false
	$"野马行动框".visible = false
	$"拳师行动框".visible = false
	$"灵阵行动框".visible = false
	$"天谕行动框".visible = false
	$"妖术行动框".visible = false
	$"鼓舞行动框".visible = false
	$"转型弹框".visible = false
	$"取消".visible = false

func updateTurnTime(data):
	if data.time == "00:30":
		$"回合时间/AnimationPlayer".play("闪烁")
	$"回合时间".text = "回合时间："+data.time

func updateSwordOrder(action:int):
	$"能量".text = "能量："+String.num_int64(action)
	playSwordOrderChangeAnim()

func playSwordOrderChangeAnim():
	$"能量/AnimationPlayer".play("变化提醒")

# 点击其他玩家的棋子
func clickOthers():
	$"取消".visible = true

# 鼠标进入技能按钮，准备展示技能描述，开启定时1s
func wantShowDesc(msg:String):
	$"技能描述".startTimer(msg)

# 关闭技能描述框 或者 鼠标移除技能按钮，取消展示技能描述
func closeDesc():
	$"技能描述".stopTimer()

func clickSmall():
	$"小子行动框".visible = true
	$"取消".visible = true

func clickBig():
	$"大子行动框".visible = true
	$"取消".visible = true

func click幽灵():
	$"幽灵行动框".visible = true
	$"取消".visible = true

func click恶灵():
	$"恶灵行动框".visible = true
	$"取消".visible = true

func click顽石():
	$"取消".visible = true

func click炮台():
	$"炮台行动框".visible = true
	$"取消".visible = true

func click狙炮():
	$"狙炮行动框".visible = true
	$"取消".visible = true

func click地灵():
	$"地灵行动框".visible = true
	$"取消".visible = true

func click精灵():
	$"精灵行动框".visible = true
	$"取消".visible = true

func click沙兵():
	$"沙兵行动框".visible = true
	$"取消".visible = true

func click沙皇():
	$"沙皇行动框".visible = true
	$"取消".visible = true

func click野猪():
	$"野猪行动框".visible = true
	$"取消".visible = true

func click野马():
	$"野马行动框".visible = true
	$"取消".visible = true

func click拳师():
	$"拳师行动框".visible = true
	$"取消".visible = true

func click灵阵():
	$"灵阵行动框".visible = true
	$"取消".visible = true

func click天谕():
	$"天谕行动框".visible = true
	$"取消".visible = true

func click妖术():
	$"妖术行动框".visible = true
	$"取消".visible = true

func click鼓舞():
	$"鼓舞行动框".visible = true
	$"取消".visible = true

func _on_取消_pressed():
	ObjectManager.soundManager.play(SoundType.close_cancel)
	closeAll()

func closeAll():
	ObjectManager.gameManager.operationManager.cancel()
	closeDesc()
	$"小子行动框".visible = false
	$"大子行动框".visible = false
	$"幽灵行动框".visible = false
	$"恶灵行动框".visible = false
	$"炮台行动框".visible = false
	$"狙炮行动框".visible = false
	$"地灵行动框".visible = false
	$"精灵行动框".visible = false
	$"沙兵行动框".visible = false
	$"沙皇行动框".visible = false
	$"野猪行动框".visible = false
	$"野马行动框".visible = false
	$"拳师行动框".visible = false
	$"灵阵行动框".visible = false
	$"天谕行动框".visible = false
	$"妖术行动框".visible = false
	$"鼓舞行动框".visible = false
	$"取消".visible = false
	if $"转型弹框".visible:
		$"转型弹框".get_node("AnimationPlayer").play("close")

func gameOver(username:String):
	$"结束弹框".show_dialog(username)


func _on_设置_pressed():
	ObjectManager.soundManager.play(SoundType.button_click)
	ObjectManager.main.switch_settings()
